//
//  UIColor+Expand.m
//  IkongWuProgram
//
//  Created by 谢志振 on 16/3/9.
//  Copyright © 2016年 Vdianjing. All rights reserved.
//

#import "UIColor+Expand.h"

@implementation UIColor (Expand)

+(UIColor *)colorFromHexString:(NSString *)hexString
{
    return [self  colorFromHexString:hexString alpha:1.0];
}

+(UIColor *)colorWithR:(CGFloat)red G:(CGFloat)green B:(CGFloat)blue A:(CGFloat)alpha
{
    return [UIColor colorWithRed:red/255.0 green:green/255.0 blue:blue/255.0 alpha:alpha];
}

+(UIColor *)colorFromHexString:(NSString *)hexString alpha:(CGFloat)alpha
{
    unsigned rgbValue = 0;
    hexString = [hexString stringByReplacingOccurrencesOfString:@"#" withString:@""];
    NSScanner *scanner = [NSScanner scannerWithString:hexString];
    [scanner scanHexInt:&rgbValue];
    
    return [self colorWithR:((rgbValue & 0xFF0000) >> 16) G:((rgbValue & 0xFF00) >> 8) B:(rgbValue & 0xFF) A:alpha];
}

@end
